﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace zjbks
{
    public partial class AdminDel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            //    if (Request.QueryString["id"] != null)
            //    {
            //        int id = int.Parse(Request.QueryString["id"].ToString());
            //        GetData(id);//获取数据
            //    }
            //}
        }
        /// <summary>
        /// 获取数据并展示
        /// </summary>
        /// <param name="id"></param>
        public void GetData(int id)
        {
            //DALadmin_user dal = new DALadmin_user();
            //admin_userEntity admin = dal.Getadmin_user(id);
            //ViewState["admin"] = admin;//在当前页缓存数据。
            //xm.Text = admin.TrueName;//加载显示数据

            //将取回的数据在页面进行展示，可以修改的数据使用TextBox来展示，并提供修改。
            //通过按钮触发，实现将数据编辑保存的功能
        }
        /// <summary>
        /// 保存修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            //DALadmin_user dal = new DALadmin_user();
            //admin_userEntity admin = (admin_userEntity)ViewState["admin"];//获取缓存数据
            //admin.TrueName = xm.Text;//修改数据
            //dal.Modadmin_user(admin);//提交到数据库
            Model.UserInfoEntity user = new Model.UserInfoEntity();
            user.ID = id.Text;
            BLL.BUserInfo bUser = new BLL.BUserInfo();
            Model.UserInfoEntity user1 = new Model.UserInfoEntity();
            user1 = bUser.GetUserInfo(user.ID);
            if(user1!=null)
            {
                if(bUser.DelUserInfo(user.ID)>0)
                {
                    //成功
                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除成功！');</script>");
                }
                else
                {
                    //失败
                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除失败！');</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('没有此用户！');</script>");
            }
        }
    }
}